﻿using System.Linq.Expressions;

using Tszy.Unlimited.Data.AdoNet.Sql.Components.Visitors;

namespace Tszy.Unlimited.Data.AdoNet.Sql.Components.Expressions.Values
{
    internal interface IValueExpressionHandler
    {
        ValueExpressionResult Handler(ExpressionContext context, Expression expression);
    }

    internal abstract class ValueExpressionHandlerBase : IValueExpressionHandler
    {
        protected IEvaluator Evaluator { get; } = new CacheEvaluator();

        protected virtual ValueExpressionResult ResultSuccess()
        {
            return new ValueExpressionResult { Status = true };
        }

        protected virtual ValueExpressionResult ResultError()
        {
            return new ValueExpressionResult { Status = false };
        }

        public abstract ValueExpressionResult Handler(ExpressionContext context, Expression expression);
    }
}